import compluginBabel from './index'

export default function (this: any, options: compluginBabel.Options) {
  // install webpack plugin
  this.extendBuild((config: any) => {
    const plugins = config.plugins ?? (config.plugins = [])
    plugins.unshift(compluginBabel.webpack(options))
  })

  // install vite plugin
  this.nuxt.hook('vite:extend', async (vite: any) => {
    const plugins = vite.config.plugins ?? (vite.config.plugins = [])
    plugins.push(compluginBabel.vite(options))
  })
}
